<script setup>
import {ref} from "vue";
import request9191 from "../../../utils/request9191.js";
import {ElMessage} from "element-plus";

const clubActivityData=ref()

const getClubActivity = () =>{
  request9191({
    url: "/clubActivity/getAll",
    method: 'get'
  }).then((res) =>{
    clubActivityData.value=res.data.data
  })
}


const updateModStatus = (status , id) =>{
  request9191({
    url: '/clubActivity/ModStatus',
    method: 'put',
    params:{
      status:status,
      id:id
    }
  }).then((res)=>{
    if (res.data.data === 1){
      ElMessage.success("已通过")
    }else {
      ElMessage.info("已驳回")
    }
    getClubActivity()
  })
}
getClubActivity()
</script>

<template>
  <div class="clubActivity">
    <el-table :data="clubActivityData">
      <el-table-column prop="id" label="ID"/>
      <el-table-column prop="actName" label="活动名称"/>
      <el-table-column prop="actSummarize" label="活动概述"/>
      <el-table-column prop="actParticulars" label="活动详情"/>
      <el-table-column prop="actPeople" label="活动人数"/>
      <el-table-column prop="actTime" label="报名时间"/>
      <el-table-column prop="actClub" label="发布社团"/>
      <el-table-column prop="actAsk" label="活动要求"/>
      <el-table-column prop="actBeginTime" label="活动时间"/>
      <el-table-column label="状态" width="100px">
        <template #default="scope">
          <el-tag v-if="scope.row.status === 0" type="warning">待审核</el-tag>
          <el-tag v-else-if="scope.row.status === 1" type="success">已通过</el-tag>
          <el-tag v-else type="danger">已驳回</el-tag>
        </template>
      </el-table-column>

      <el-table-column  label="审核" width="150px">
        <template #default="scope">
          <el-button size="small" type="success" @click="updateModStatus('1',scope.row.id)">通过</el-button>
          <el-button size="small" type="danger" @click="updateModStatus('2' , scope.row.id)">驳回</el-button>
        </template>
      </el-table-column>
    </el-table>


  </div>
</template>

<style scoped>

</style>